/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Oct 22, 2011    @time-created 5:02:42 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import util.enumeration.UserRoleType;

@Entity(name="UserRole")
public class UserRoleEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private UserRoleType userRoleType;
    
    // bidirectional (not owning side) to StaffAccountEntity (owning side)
    @OneToMany(cascade={CascadeType.PERSIST}, mappedBy="UserRole")
    private Collection<StaffAccountEntity> staffAccounts;
    
    @OneToMany(cascade = {CascadeType.ALL})
    private List<UserRoleAccessRightsEntity> userRoleAccessRights = new ArrayList<UserRoleAccessRightsEntity>();

    public UserRoleEntity() {
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public UserRoleType getUserRoleType() {
        return userRoleType;
    }

    public void setUserRoleType(UserRoleType userRoleType) {
        this.userRoleType = userRoleType;
    }

    public List<UserRoleAccessRightsEntity> getUserRoleAccessRights() {
        return userRoleAccessRights;
    }

    public void setUserRoleAccessRights(List<UserRoleAccessRightsEntity> userRoleAccessRights) {
        this.userRoleAccessRights = userRoleAccessRights;
    }

    public Collection<StaffAccountEntity> getStaffAccounts() {
        return staffAccounts;
    }

    public void setStaffAccounts(Collection<StaffAccountEntity> staffAccounts) {
        this.staffAccounts = staffAccounts;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserRoleEntity)) {
            return false;
        }
        UserRoleEntity other = (UserRoleEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.RoleEntity[ id=" + id + " ]";
    }
    
}
